package com.chlitina.store.modules.cash.entity;

import java.util.Date;

import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.Table;

import org.hibernate.annotations.Cache;
import org.hibernate.annotations.CacheConcurrencyStrategy;
import org.hibernate.annotations.NotFound;
import org.hibernate.annotations.NotFoundAction;

import com.chlitina.store.common.persistence.BaseEntity;
import com.chlitina.store.modules.base.entity.Customer;
import com.chlitina.store.modules.base.entity.StoreCardTemplateDuration;
import com.chlitina.store.modules.sys.entity.Store;

/**
 * 产品卡
 * @author Songsong.Xu 2013-11-15
 *
 */
@Entity
@Table(name = "store_card_duration")
@Cache(usage = CacheConcurrencyStrategy.READ_WRITE)
public class StoreCardDuration  extends BaseEntity{
	private static final long serialVersionUID = 1L;
	private Long id; 		// 编号
	private StoreCardTemplateDuration template;
	private String cardNumber;
	private Store store;  // 店面
	private Customer customer;
	private Date beginTime;//开卡时间
	private Date endTime;//到期时间
	private int lastRechargeDuration;//最后一次充值数量：充了几个月？
	private int status;//会员卡状态  0-可用,1-不可用



	@Id
	@Column( name="ID")
	@GeneratedValue(strategy = GenerationType.IDENTITY)
	public Long getId() {
		return id;
	}
	
	
	public void setId(Long id) {
		this.id = id;
	}

	@ManyToOne(cascade={CascadeType.REFRESH}, fetch = FetchType.LAZY) 
	@JoinColumn(name="CARD_TEMPLATE_ID")
	@NotFound(action = NotFoundAction.IGNORE)
	@Cache(usage = CacheConcurrencyStrategy.READ_WRITE)
	public StoreCardTemplateDuration getTemplate() {
		return template;
	}


	public void setTemplate(StoreCardTemplateDuration template) {
		this.template = template;
	}

	@Column(name="CARD_NUMBER")
	public String getCardNumber() {
		return cardNumber;
	}


	public void setCardNumber(String cardNumber) {
		this.cardNumber = cardNumber;
	}

	@ManyToOne(cascade={CascadeType.REFRESH}, fetch = FetchType.LAZY) 
	@JoinColumn(name="STORE_ID")
	@NotFound(action = NotFoundAction.IGNORE)
	@Cache(usage = CacheConcurrencyStrategy.READ_WRITE)
	public Store getStore() {
		return store;
	}


	public void setStore(Store store) {
		this.store = store;
	}

	@ManyToOne(cascade={CascadeType.REFRESH}, fetch = FetchType.LAZY) 
	@JoinColumn(name="CUSTOMER_ID")
	@NotFound(action = NotFoundAction.IGNORE)
	@Cache(usage = CacheConcurrencyStrategy.READ_WRITE)
	public Customer getCustomer() {
		return customer;
	}


	public void setCustomer(Customer customer) {
		this.customer = customer;
	}

	@Column(name="BEGIN_TIME")
	public Date getBeginTime() {
		return beginTime;
	}


	public void setBeginTime(Date beginTime) {
		this.beginTime = beginTime;
	}

 

	@Column(name="STATUS")
	public int getStatus() {
		return status;
	}


	public void setStatus(int status) {
		this.status = status;
	}

	
	@Column(name="END_TIME")
	public Date getEndTime() {
		return endTime;
	}


	public void setEndTime(Date endTime) {
		this.endTime = endTime;
	}

	@Column(name="LAST_RECHARGE_DURATION")
	public int getLastRechargeDuration() {
		return lastRechargeDuration;
	}


	public void setLastRechargeDuration(int lastRechargeDuration) {
		this.lastRechargeDuration = lastRechargeDuration;
	}
}
